home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc263-src.lha / gcc-2.6.3 / c-parse.y < prev    next >
GNU Bison Grammar  |  1994-08-27  |  57KB  |  1,949 lines

  1. /* YACC parser for C syntax and for Objective C.  -*-c-*-
  2.    Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* This file defines the grammar of C and that of Objective C.
  21.    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
  22.    ifc ... end ifc  conditionals contain code for C only.
  23.    Sed commands in Makefile.in are used to convert this file into
  24.    c-parse.y and into objc-parse.y.  */
  25.  
  26. /* To whomever it may concern: I have heard that such a thing was once
  27. written by AT&T, but I have never seen it.  */
  28.  
  29. %expect 10
  30.  
  31. /* These are the 10 conflicts you should get in parse.output;
  32.    the state numbers may vary if minor changes in the grammar are made.
  33.  
  34. State 41 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  35. State 97 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  36. State 104 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  37. State 108 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  38. State 124 contains 1 shift/reduce conflict.  (See comment at component_decl.)
  39. State 191 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  40. State 204 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  41. State 210 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  42. State 449 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  43. */
  44.  
  45. %{
  46. #include <stdio.h>
  47. #include <errno.h>
  48. #include <setjmp.h>
  49.  
  50. #include "config.h"
  51. #include "tree.h"
  52. #include "input.h"
  53. #include "c-lex.h"
  54. #include "c-tree.h"
  55. #include "flags.h"
  56.  
  57. #ifdef MULTIBYTE_CHARS
  58. #include <stdlib.h>
  59. #include <locale.h>
  60. #endif
  61.  
  62.  
  63. /* Since parsers are distinct for each language, put the language string
  64.    definition here.  */
  65. char *language_string = "GNU C";
  66.  
  67. #ifndef errno
  68. extern int errno;
  69. #endif
  70.  
  71. void yyerror ();
  72.  
  73. /* Like YYERROR but do call yyerror.  */
  74. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  75.  
  76. /* Cause the `yydebug' variable to be defined.  */
  77. #define YYDEBUG 1
  78. %}
  79.  
  80. %start program
  81.  
  82. %union {long itype; tree ttype; enum tree_code code;
  83.     char *filename; int lineno; }
  84.  
  85. /* All identifiers that are not reserved words
  86.    and are not declared typedefs in the current block */
  87. %token IDENTIFIER
  88.  
  89. /* All identifiers that are declared typedefs in the current block.
  90.    In some contexts, they are treated just like IDENTIFIER,
  91.    but they can also serve as typespecs in declarations.  */
  92. %token TYPENAME
  93.  
  94. /* Reserved words that specify storage class.
  95.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  96. %token SCSPEC
  97.  
  98. /* Reserved words that specify type.
  99.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  100. %token TYPESPEC
  101.  
  102. /* Reserved words that qualify type: "const" or "volatile".
  103.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  104. %token TYPE_QUAL
  105.  
  106. /* Character or numeric constants.
  107.    yylval is the node for the constant.  */
  108. %token CONSTANT
  109.  
  110. /* String constants in raw form.
  111.    yylval is a STRING_CST node.  */
  112. %token STRING
  113.  
  114. /* "...", used for functions with variable arglists.  */
  115. %token ELLIPSIS
  116.  
  117. /* the reserved words */
  118. /* SCO include files test "ASM", so use something else. */
  119. %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  120. %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF ALIGN
  121. %token ATTRIBUTE EXTENSION LABEL
  122. %token REALPART IMAGPART
  123.  
  124. /* Add precedence rules to solve dangling else s/r conflict */
  125. %nonassoc IF
  126. %nonassoc ELSE
  127.  
  128. /* Define the operator tokens and their precedences.
  129.    The value is an integer because, if used, it is the tree code
  130.    to use in the expression made from the operator.  */
  131.  
  132. %right <code> ASSIGN '='
  133. %right <code> '?' ':'
  134. %left <code> OROR
  135. %left <code> ANDAND
  136. %left <code> '|'
  137. %left <code> '^'
  138. %left <code> '&'
  139. %left <code> EQCOMPARE
  140. %left <code> ARITHCOMPARE
  141. %left <code> LSHIFT RSHIFT
  142. %left <code> '+' '-'
  143. %left <code> '*' '/' '%'
  144. %right <code> UNARY PLUSPLUS MINUSMINUS
  145. %left HYPERUNARY
  146. %left <code> POINTSAT '.' '(' '['
  147.  
  148. /* The Objective-C keywords.  These are included in C and in
  149.    Objective C, so that the token codes are the same in both.  */
  150. %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
  151. %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
  152.  
  153. /* Objective-C string constants in raw form.
  154.    yylval is an OBJC_STRING_CST node.  */
  155. %token OBJC_STRING
  156.  
  157.  
  158. %type <code> unop
  159.  
  160. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
  161. %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
  162. %type <ttype> typed_declspecs reserved_declspecs
  163. %type <ttype> typed_typespecs reserved_typespecquals
  164. %type <ttype> declmods typespec typespecqual_reserved
  165. %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
  166. %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
  167. %type <ttype> init maybeasm
  168. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  169. %type <ttype> maybe_attribute attributes attribute attribute_list attrib
  170. %type <ttype> any_word
  171.  
  172. %type <ttype> compstmt
  173.  
  174. %type <ttype> declarator
  175. %type <ttype> notype_declarator after_type_declarator
  176. %type <ttype> parm_declarator
  177.  
  178. %type <ttype> structsp component_decl_list component_decl_list2
  179. %type <ttype> component_decl components component_declarator
  180. %type <ttype> enumlist enumerator
  181. %type <ttype> typename absdcl absdcl1 type_quals
  182. %type <ttype> xexpr parms parm identifiers
  183.  
  184. %type <ttype> parmlist parmlist_1 parmlist_2
  185. %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
  186. %type <ttype> identifiers_or_typenames
  187.  
  188. %type <itype> setspecs
  189.  
  190. %type <filename> save_filename
  191. %type <lineno> save_lineno
  192.  
  193.  
  194. %{
  195. /* Number of statements (loosely speaking) seen so far.  */
  196. static int stmt_count;
  197.  
  198. /* Input file and line number of the end of the body of last simple_if;
  199.    used by the stmt-rule immediately after simple_if returns.  */
  200. static char *if_stmt_file;
  201. static int if_stmt_line;
  202.  
  203. /* List of types and structure classes of the current declaration.  */
  204. static tree current_declspecs;
  205.  
  206. /* Stack of saved values of current_declspecs.  */
  207. static tree declspec_stack;
  208.  
  209. /* 1 if we explained undeclared var errors.  */
  210. static int undeclared_variable_notice;
  211.  
  212.  
  213. /* Tell yyparse how to print a token's value, if yydebug is set.  */
  214.  
  215. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  216. extern void yyprint ();
  217. %}
  218.  
  219. %%
  220. program: /* empty */
  221.         { if (pedantic)
  222.             pedwarn ("ANSI C forbids an empty source file");
  223.         }
  224.     | extdefs
  225.         {
  226.           /* In case there were missing closebraces,
  227.              get us back to the global binding level.  */
  228.           while (! global_bindings_p ())
  229.             poplevel (0, 0, 0);
  230.         }
  231.     ;
  232.  
  233. /* the reason for the strange actions in this rule
  234.  is so that notype_initdecls when reached via datadef
  235.  can find a valid list of type and sc specs in $0. */
  236.  
  237. extdefs:
  238.     {$<ttype>$ = NULL_TREE; } extdef
  239.     | extdefs {$<ttype>$ = NULL_TREE; } extdef
  240.     ;
  241.  
  242. extdef:
  243.     fndef
  244.     | datadef
  245.     | ASM_KEYWORD '(' expr ')' ';'
  246.         { STRIP_NOPS ($3);
  247.           if ((TREE_CODE ($3) == ADDR_EXPR
  248.                && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
  249.               || TREE_CODE ($3) == STRING_CST)
  250.             assemble_asm ($3);
  251.           else
  252.             error ("argument of `asm' is not a constant string"); }
  253.     ;
  254.  
  255. datadef:
  256.       setspecs notype_initdecls ';'
  257.         { if (pedantic)
  258.             error ("ANSI C forbids data definition with no type or storage class");
  259.           else if (!flag_traditional)
  260.             warning ("data definition has no type or storage class"); }
  261.         | declmods setspecs notype_initdecls ';'
  262.       {}
  263.     | typed_declspecs setspecs initdecls ';'
  264.       {}
  265.         | declmods ';'
  266.       { pedwarn ("empty declaration"); }
  267.     | typed_declspecs ';'
  268.       { shadow_tag ($1); }
  269.     | error ';'
  270.     | error '}'
  271.     | ';'
  272.         { if (pedantic)
  273.             pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
  274.     ;
  275.  
  276. fndef:
  277.       typed_declspecs setspecs declarator
  278.         { if (! start_function ($1, $3, 0))
  279.             YYERROR1;
  280.           reinit_parse_for_function (); }
  281.       xdecls
  282.         { store_parm_decls (); }
  283.       compstmt_or_error
  284.         { finish_function (0); }
  285.     | typed_declspecs setspecs declarator error
  286.         { }
  287.     | declmods setspecs notype_declarator
  288.         { if (! start_function ($1, $3, 0))
  289.             YYERROR1;
  290.           reinit_parse_for_function (); }
  291.       xdecls
  292.         { store_parm_decls (); }
  293.       compstmt_or_error
  294.         { finish_function (0); }
  295.     | declmods setspecs notype_declarator error
  296.         { }
  297.     | setspecs notype_declarator
  298.         { if (! start_function (NULL_TREE, $2, 0))
  299.             YYERROR1;
  300.           reinit_parse_for_function (); }
  301.       xdecls
  302.         { store_parm_decls (); }
  303.       compstmt_or_error
  304.         { finish_function (0); }
  305.     | setspecs notype_declarator error
  306.         { }
  307.     ;
  308.  
  309. identifier:
  310.     IDENTIFIER
  311.     | TYPENAME
  312.     ;
  313.  
  314. unop:     '&'
  315.         { $$ = ADDR_EXPR; }
  316.     | '-'
  317.         { $$ = NEGATE_EXPR; }
  318.     | '+'
  319.         { $$ = CONVERT_EXPR; }
  320.     | PLUSPLUS
  321.         { $$ = PREINCREMENT_EXPR; }
  322.     | MINUSMINUS
  323.         { $$ = PREDECREMENT_EXPR; }
  324.     | '~'
  325.         { $$ = BIT_NOT_EXPR; }
  326.     | '!'
  327.         { $$ = TRUTH_NOT_EXPR; }
  328.     ;
  329.  
  330. expr:    nonnull_exprlist
  331.         { $$ = build_compound_expr ($1); }
  332.     ;
  333.  
  334. exprlist:
  335.       /* empty */
  336.         { $$ = NULL_TREE; }
  337.     | nonnull_exprlist
  338.     ;
  339.  
  340. nonnull_exprlist:
  341.     expr_no_commas
  342.         { $$ = build_tree_list (NULL_TREE, $1); }
  343.     | nonnull_exprlist ',' expr_no_commas
  344.         { chainon ($1, build_tree_list (NULL_TREE, $3)); }
  345.     ;
  346.  
  347. unary_expr:
  348.     primary
  349.     | '*' cast_expr   %prec UNARY
  350.         { $$ = build_indirect_ref ($2, "unary *"); }
  351.     /* __extension__ turns off -pedantic for following primary.  */
  352.     | EXTENSION
  353.         { $<itype>1 = pedantic;
  354.           pedantic = 0; }
  355.       cast_expr      %prec UNARY
  356.         { $$ = $3;
  357.           pedantic = $<itype>1; }
  358.     | unop cast_expr  %prec UNARY
  359.         { $$ = build_unary_op ($1, $2, 0);
  360.           overflow_warning ($$); }
  361.     /* Refer to the address of a label as a pointer.  */
  362.     | ANDAND identifier
  363.         { tree label = lookup_label ($2);
  364.           if (label == 0)
  365.             $$ = null_pointer_node;
  366.           else
  367.             {
  368.               TREE_USED (label) = 1;
  369.               $$ = build1 (ADDR_EXPR, ptr_type_node, label);
  370.               TREE_CONSTANT ($$) = 1;
  371.             }
  372.         }
  373. /* This seems to be impossible on some machines, so let's turn it off.
  374.    You can use __builtin_next_arg to find the anonymous stack args.
  375.     | '&' ELLIPSIS
  376.         { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
  377.           $$ = error_mark_node;
  378.           if (TREE_VALUE (tree_last (types)) == void_type_node)
  379.             error ("`&...' used in function with fixed number of arguments");
  380.           else
  381.             {
  382.               if (pedantic)
  383.             pedwarn ("ANSI C forbids `&...'");
  384.               $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
  385.               $$ = build_unary_op (ADDR_EXPR, $$, 0);
  386.             } }
  387. */
  388.     | SIZEOF unary_expr  %prec UNARY
  389.         { if (TREE_CODE ($2) == COMPONENT_REF
  390.               && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
  391.             error ("`sizeof' applied to a bit-field");
  392.           $$ = c_sizeof (TREE_TYPE ($2)); }
  393.     | SIZEOF '(' typename ')'  %prec HYPERUNARY
  394.         { $$ = c_sizeof (groktypename ($3)); }
  395.     | ALIGNOF unary_expr  %prec UNARY
  396.         { $$ = c_alignof_expr ($2); }
  397.     | ALIGNOF '(' typename ')'  %prec HYPERUNARY
  398.         { $$ = c_alignof (groktypename ($3)); }
  399.     | REALPART cast_expr %prec UNARY
  400.         { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
  401.     | IMAGPART cast_expr %prec UNARY
  402.         { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
  403.     ;
  404.  
  405. cast_expr:
  406.     unary_expr
  407.     | '(' typename ')' cast_expr  %prec UNARY
  408.         { tree type = groktypename ($2);
  409.           $$ = build_c_cast (type, $4); }
  410.     | '(' typename ')' '{' 
  411.         { start_init (NULL_TREE, NULL, 0);
  412.           $2 = groktypename ($2);
  413.           really_start_incremental_init ($2); }
  414.       initlist_maybe_comma '}'  %prec UNARY
  415.         { char *name;
  416.           tree result = pop_init_level (0);
  417.           tree type = $2;
  418.           finish_init ();
  419.  
  420.           if (pedantic)
  421.             pedwarn ("ANSI C forbids constructor expressions");
  422.           if (TYPE_NAME (type) != 0)
  423.             {
  424.               if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  425.             name = IDENTIFIER_POINTER (TYPE_NAME (type));
  426.               else
  427.             name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
  428.             }
  429.           else
  430.             name = "";
  431.           $$ = result;
  432.           if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
  433.             {
  434.               int failure = complete_array_type (type, $$, 1);
  435.               if (failure)
  436.             abort ();
  437.             }
  438.         }
  439.     ;
  440.  
  441. expr_no_commas:
  442.       cast_expr
  443.     | expr_no_commas '+' expr_no_commas
  444.         { $$ = parser_build_binary_op ($2, $1, $3); }
  445.     | expr_no_commas '-' expr_no_commas
  446.         { $$ = parser_build_binary_op ($2, $1, $3); }
  447.     | expr_no_commas '*' expr_no_commas
  448.         { $$ = parser_build_binary_op ($2, $1, $3); }
  449.     | expr_no_commas '/' expr_no_commas
  450.         { $$ = parser_build_binary_op ($2, $1, $3); }
  451.     | expr_no_commas '%' expr_no_commas
  452.         { $$ = parser_build_binary_op ($2, $1, $3); }
  453.     | expr_no_commas LSHIFT expr_no_commas
  454.         { $$ = parser_build_binary_op ($2, $1, $3); }
  455.     | expr_no_commas RSHIFT expr_no_commas
  456.         { $$ = parser_build_binary_op ($2, $1, $3); }
  457.     | expr_no_commas ARITHCOMPARE expr_no_commas
  458.         { $$ = parser_build_binary_op ($2, $1, $3); }
  459.     | expr_no_commas EQCOMPARE expr_no_commas
  460.         { $$ = parser_build_binary_op ($2, $1, $3); }
  461.     | expr_no_commas '&' expr_no_commas
  462.         { $$ = parser_build_binary_op ($2, $1, $3); }
  463.     | expr_no_commas '|' expr_no_commas
  464.         { $$ = parser_build_binary_op ($2, $1, $3); }
  465.     | expr_no_commas '^' expr_no_commas
  466.         { $$ = parser_build_binary_op ($2, $1, $3); }
  467.     | expr_no_commas ANDAND expr_no_commas
  468.         { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
  469.     | expr_no_commas OROR expr_no_commas
  470.         { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
  471.     | expr_no_commas '?' xexpr ':' expr_no_commas
  472.         { $$ = build_conditional_expr ($1, $3, $5); }
  473.     | expr_no_commas '=' expr_no_commas
  474.         { $$ = build_modify_expr ($1, NOP_EXPR, $3);
  475.           C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
  476.     | expr_no_commas ASSIGN expr_no_commas
  477.         { $$ = build_modify_expr ($1, $2, $3);
  478.           /* This inhibits warnings in truthvalue_conversion.  */
  479.           C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
  480.     ;
  481.  
  482. primary:
  483.     IDENTIFIER
  484.         {
  485.           $$ = lastiddecl;
  486.           if (!$$ || $$ == error_mark_node)
  487.             {
  488.               if (yychar == YYEMPTY)
  489.             yychar = YYLEX;
  490.               if (yychar == '(')
  491.             {
  492.                 {
  493.                   /* Ordinary implicit function declaration.  */
  494.                   $$ = implicitly_declare ($1);
  495.                   assemble_external ($$);
  496.                   TREE_USED ($$) = 1;
  497.                 }
  498.             }
  499.               else if (current_function_decl == 0)
  500.             {
  501.               error ("`%s' undeclared here (not in a function)",
  502.                  IDENTIFIER_POINTER ($1));
  503.               $$ = error_mark_node;
  504.             }
  505.               else
  506.             {
  507.                 {
  508.                   if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
  509.                   || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
  510.                 {
  511.                   error ("`%s' undeclared (first use this function)",
  512.                      IDENTIFIER_POINTER ($1));
  513.  
  514.                   if (! undeclared_variable_notice)
  515.                     {
  516.                       error ("(Each undeclared identifier is reported only once");
  517.                       error ("for each function it appears in.)");
  518.                       undeclared_variable_notice = 1;
  519.                     }
  520.                 }
  521.                   $$ = error_mark_node;
  522.                   /* Prevent repeated error messages.  */
  523.                   IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
  524.                   IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
  525.                 }
  526.             }
  527.             }
  528.           else if (TREE_TYPE ($$) == error_mark_node)
  529.             $$ = error_mark_node;
  530.           else if (C_DECL_ANTICIPATED ($$))
  531.             {
  532.               /* The first time we see a build-in function used,
  533.              if it has not been declared.  */
  534.               C_DECL_ANTICIPATED ($$) = 0;
  535.               if (yychar == YYEMPTY)
  536.             yychar = YYLEX;
  537.               if (yychar == '(')
  538.             {
  539.               /* Omit the implicit declaration we
  540.                  would ordinarily do, so we don't lose
  541.                  the actual built in type.
  542.                  But print a diagnostic for the mismatch.  */
  543.                 if (TREE_CODE ($$) != FUNCTION_DECL)
  544.                   error ("`%s' implicitly declared as function",
  545.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  546.               else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
  547.                     != TYPE_MODE (integer_type_node))
  548.                    && (TREE_TYPE (TREE_TYPE ($$))
  549.                        != void_type_node))
  550.                 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
  551.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  552.               /* If it really returns void, change that to int.  */
  553.               if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
  554.                 TREE_TYPE ($$)
  555.                   = build_function_type (integer_type_node,
  556.                              TYPE_ARG_TYPES (TREE_TYPE ($$)));
  557.             }
  558.               else
  559.             pedwarn ("built-in function `%s' used without declaration",
  560.                  IDENTIFIER_POINTER (DECL_NAME ($$)));
  561.  
  562.               /* Do what we would ordinarily do when a fn is used.  */
  563.               assemble_external ($$);
  564.               TREE_USED ($$) = 1;
  565.             }
  566.           else
  567.             {
  568.               assemble_external ($$);
  569.               TREE_USED ($$) = 1;
  570.             }
  571.  
  572.           if (TREE_CODE ($$) == CONST_DECL)
  573.             {
  574.               $$ = DECL_INITIAL ($$);
  575.               /* This is to prevent an enum whose value is 0
  576.              from being considered a null pointer constant.  */
  577.               $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
  578.               TREE_CONSTANT ($$) = 1;
  579.             }
  580.         }
  581.     | CONSTANT
  582.     | string
  583.         { $$ = combine_strings ($1); }
  584.     | '(' expr ')'
  585.         { char class = TREE_CODE_CLASS (TREE_CODE ($2));
  586.           if (class == 'e' || class == '1'
  587.               || class == '2' || class == '<')
  588.             C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
  589.           $$ = $2; }
  590.     | '(' error ')'
  591.         { $$ = error_mark_node; }
  592.     | '('
  593.         { if (current_function_decl == 0)
  594.             {
  595.               error ("braced-group within expression allowed only inside a function");
  596.               YYERROR;
  597.             }
  598.           /* We must force a BLOCK for this level
  599.              so that, if it is not expanded later,
  600.              there is a way to turn off the entire subtree of blocks
  601.              that are contained in it.  */
  602.           keep_next_level ();
  603.           push_iterator_stack ();
  604.           push_label_level ();
  605.           $<ttype>$ = expand_start_stmt_expr (); }
  606.       compstmt ')'
  607.         { tree rtl_exp;
  608.           if (pedantic)
  609.             pedwarn ("ANSI C forbids braced-groups within expressions");
  610.           pop_iterator_stack ();
  611.           pop_label_level ();
  612.           rtl_exp = expand_end_stmt_expr ($<ttype>2);
  613.           /* The statements have side effects, so the group does.  */
  614.           TREE_SIDE_EFFECTS (rtl_exp) = 1;
  615.  
  616.           if (TREE_CODE ($3) == BLOCK)
  617.             {
  618.               /* Make a BIND_EXPR for the BLOCK already made.  */
  619.               $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
  620.                   NULL_TREE, rtl_exp, $3);
  621.               /* Remove the block from the tree at this point.
  622.              It gets put back at the proper place
  623.              when the BIND_EXPR is expanded.  */
  624.               delete_block ($3);
  625.             }
  626.           else
  627.             $$ = $3;
  628.         }
  629.     | primary '(' exprlist ')'   %prec '.'
  630.         { $$ = build_function_call ($1, $3); }
  631.     | primary '[' expr ']'   %prec '.'
  632.         { $$ = build_array_ref ($1, $3); }
  633.     | primary '.' identifier
  634.         {
  635.             $$ = build_component_ref ($1, $3);
  636.         }
  637.     | primary POINTSAT identifier
  638.         {
  639.                   tree expr = build_indirect_ref ($1, "->");
  640.  
  641.                     $$ = build_component_ref (expr, $3);
  642.         }
  643.     | primary PLUSPLUS
  644.         { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
  645.     | primary MINUSMINUS
  646.         { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
  647.     ;
  648.  
  649. /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
  650. string:
  651.       STRING
  652.     | string STRING
  653.         { $$ = chainon ($1, $2); }
  654.     ;
  655.  
  656.  
  657. xdecls:
  658.     /* empty */
  659.     | datadecls
  660.     | datadecls ELLIPSIS
  661.         /* ... is used here to indicate a varargs function.  */
  662.         { c_mark_varargs ();
  663.           if (pedantic)
  664.             pedwarn ("ANSI C does not permit use of `varargs.h'"); }
  665.     ;
  666.  
  667. /* The following are analogous to lineno_decl, decls and decl
  668.    except that they do not allow nested functions.
  669.    They are used for old-style parm decls.  */
  670. lineno_datadecl:
  671.       save_filename save_lineno datadecl
  672.         { }
  673.     ;
  674.  
  675. datadecls:
  676.     lineno_datadecl
  677.     | errstmt
  678.     | datadecls lineno_datadecl
  679.     | lineno_datadecl errstmt
  680.     ;
  681.  
  682. datadecl:
  683.     typed_declspecs setspecs initdecls ';'
  684.         { current_declspecs = TREE_VALUE (declspec_stack);
  685.           declspec_stack = TREE_CHAIN (declspec_stack);
  686.           resume_momentary ($2); }
  687.     | declmods setspecs notype_initdecls ';'
  688.         { current_declspecs = TREE_VALUE (declspec_stack);
  689.           declspec_stack = TREE_CHAIN (declspec_stack);
  690.           resume_momentary ($2); }
  691.     | typed_declspecs ';'
  692.         { shadow_tag_warned ($1, 1);
  693.           pedwarn ("empty declaration"); }
  694.     | declmods ';'
  695.         { pedwarn ("empty declaration"); }
  696.     ;
  697.  
  698. /* This combination which saves a lineno before a decl
  699.    is the normal thing to use, rather than decl itself.
  700.    This is to avoid shift/reduce conflicts in contexts
  701.    where statement labels are allowed.  */
  702. lineno_decl:
  703.       save_filename save_lineno decl
  704.         { }
  705.     ;
  706.  
  707. decls:
  708.     lineno_decl
  709.     | errstmt
  710.     | decls lineno_decl
  711.     | lineno_decl errstmt
  712.     ;
  713.  
  714. /* records the type and storage class specs to use for processing
  715.    the declarators that follow.
  716.    Maintains a stack of outer-level values of current_declspecs,
  717.    for the sake of parm declarations nested in function declarators.  */
  718. setspecs: /* empty */
  719.         { $$ = suspend_momentary ();
  720.           pending_xref_error ();
  721.           declspec_stack = tree_cons (NULL_TREE, current_declspecs,
  722.                           declspec_stack);
  723.           current_declspecs = $<ttype>0; }
  724.     ;
  725.  
  726. decl:
  727.     typed_declspecs setspecs initdecls ';'
  728.         { current_declspecs = TREE_VALUE (declspec_stack);
  729.           declspec_stack = TREE_CHAIN (declspec_stack);
  730.           resume_momentary ($2); }
  731.     | declmods setspecs notype_initdecls ';'
  732.         { current_declspecs = TREE_VALUE (declspec_stack);
  733.           declspec_stack = TREE_CHAIN (declspec_stack);
  734.           resume_momentary ($2); }
  735.     | typed_declspecs setspecs nested_function
  736.         { current_declspecs = TREE_VALUE (declspec_stack);
  737.           declspec_stack = TREE_CHAIN (declspec_stack);
  738.           resume_momentary ($2); }
  739.     | declmods setspecs notype_nested_function
  740.         { current_declspecs = TREE_VALUE (declspec_stack);
  741.           declspec_stack = TREE_CHAIN (declspec_stack);
  742.           resume_momentary ($2); }
  743.     | typed_declspecs ';'
  744.         { shadow_tag ($1); }
  745.     | declmods ';'
  746.         { pedwarn ("empty declaration"); }
  747.     ;
  748.  
  749. /* Declspecs which contain at least one type specifier or typedef name.
  750.    (Just `const' or `volatile' is not enough.)
  751.    A typedef'd name following these is taken as a name to be declared.  */
  752.  
  753. typed_declspecs:
  754.       typespec reserved_declspecs
  755.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  756.     | declmods typespec reserved_declspecs
  757.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  758.     ;
  759.  
  760. reserved_declspecs:  /* empty */
  761.         { $$ = NULL_TREE; }
  762.     | reserved_declspecs typespecqual_reserved
  763.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  764.     | reserved_declspecs SCSPEC
  765.         { if (extra_warnings)
  766.             warning ("`%s' is not at beginning of declaration",
  767.                  IDENTIFIER_POINTER ($2));
  768.           $$ = tree_cons (NULL_TREE, $2, $1); }
  769.     ;
  770.  
  771. /* List of just storage classes and type modifiers.
  772.    A declaration can start with just this, but then it cannot be used
  773.    to redeclare a typedef-name.  */
  774.  
  775. declmods:
  776.       TYPE_QUAL
  777.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  778.           TREE_STATIC ($$) = 1; }
  779.     | SCSPEC
  780.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  781.     | declmods TYPE_QUAL
  782.         { $$ = tree_cons (NULL_TREE, $2, $1);
  783.           TREE_STATIC ($$) = 1; }
  784.     | declmods SCSPEC
  785.         { if (extra_warnings && TREE_STATIC ($1))
  786.             warning ("`%s' is not at beginning of declaration",
  787.                  IDENTIFIER_POINTER ($2));
  788.           $$ = tree_cons (NULL_TREE, $2, $1);
  789.           TREE_STATIC ($$) = TREE_STATIC ($1); }
  790.     ;
  791.  
  792.  
  793. /* Used instead of declspecs where storage classes are not allowed
  794.    (that is, for typenames and structure components).
  795.    Don't accept a typedef-name if anything but a modifier precedes it.  */
  796.  
  797. typed_typespecs:
  798.       typespec reserved_typespecquals
  799.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  800.     | nonempty_type_quals typespec reserved_typespecquals
  801.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  802.     ;
  803.  
  804. reserved_typespecquals:  /* empty */
  805.         { $$ = NULL_TREE; }
  806.     | reserved_typespecquals typespecqual_reserved
  807.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  808.     ;
  809.  
  810. /* A typespec (but not a type qualifier).
  811.    Once we have seen one of these in a declaration,
  812.    if a typedef name appears then it is being redeclared.  */
  813.  
  814. typespec: TYPESPEC
  815.     | structsp
  816.     | TYPENAME
  817.         { /* For a typedef name, record the meaning, not the name.
  818.              In case of `foo foo, bar;'.  */
  819.           $$ = lookup_name ($1); }
  820.     | TYPEOF '(' expr ')'
  821.         { $$ = TREE_TYPE ($3); }
  822.     | TYPEOF '(' typename ')'
  823.         { $$ = groktypename ($3); }
  824.     ;
  825.  
  826. /* A typespec that is a reserved word, or a type qualifier.  */
  827.  
  828. typespecqual_reserved: TYPESPEC
  829.     | TYPE_QUAL
  830.     | structsp
  831.     ;
  832.  
  833. initdecls:
  834.     initdcl
  835.     | initdecls ',' initdcl
  836.     ;
  837.  
  838. notype_initdecls:
  839.     notype_initdcl
  840.     | notype_initdecls ',' initdcl
  841.     ;
  842.  
  843. maybeasm:
  844.       /* empty */
  845.         { $$ = NULL_TREE; }
  846.     | ASM_KEYWORD '(' string ')'
  847.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
  848.           $$ = $3;
  849.         }
  850.     ;
  851.  
  852. initdcl:
  853.       declarator maybeasm maybe_attribute '='
  854.         { $<ttype>$ = start_decl ($1, current_declspecs, 1);
  855.           decl_attributes ($<ttype>$, $3);
  856.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  857.       init
  858. /* Note how the declaration of the variable is in effect while its init is parsed! */
  859.         { finish_init ();
  860.           decl_attributes ($<ttype>5, $3);
  861.           finish_decl ($<ttype>5, $6, $2); }
  862.     | declarator maybeasm maybe_attribute
  863.         { tree d = start_decl ($1, current_declspecs, 0);
  864.           decl_attributes (d, $3);
  865.           finish_decl (d, NULL_TREE, $2); }
  866.     ;
  867.  
  868. notype_initdcl:
  869.       notype_declarator maybeasm maybe_attribute '='
  870.         { $<ttype>$ = start_decl ($1, current_declspecs, 1);
  871.           decl_attributes ($<ttype>$, $3);
  872.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  873.       init
  874. /* Note how the declaration of the variable is in effect while its init is parsed! */
  875.         { finish_init ();
  876.           decl_attributes ($<ttype>5, $3);
  877.           finish_decl ($<ttype>5, $6, $2); }
  878.     | notype_declarator maybeasm maybe_attribute
  879.         { tree d = start_decl ($1, current_declspecs, 0);
  880.           decl_attributes (d, $3);
  881.           finish_decl (d, NULL_TREE, $2); }
  882.     ;
  883. /* the * rules are dummies to accept the Apollo extended syntax
  884.    so that the header files compile. */
  885. maybe_attribute:
  886.       /* empty */
  887.           { $$ = NULL_TREE; }
  888.     | attributes
  889.         { $$ = $1; }
  890.     ;
  891.  
  892. attributes:
  893.       attribute
  894.         { $$ = $1; }
  895.     | attributes attribute
  896.         { $$ = chainon ($1, $2); }
  897.     ;
  898.  
  899. attribute:
  900.       ATTRIBUTE '(' '(' attribute_list ')' ')'
  901.         { $$ = $4; }
  902.     ;
  903.  
  904. attribute_list:
  905.       attrib
  906.         { $$ = build_tree_list (NULL_TREE, $1); }
  907.     | attribute_list ',' attrib
  908.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  909.     ;
  910.  
  911. attrib:
  912.     /* empty */
  913.         { $$ = NULL_TREE; }
  914.     | any_word
  915.         { $$ = $1; }
  916.     | any_word '(' IDENTIFIER ')'
  917.         { $$ = tree_cons ($1, NULL_TREE,
  918.                   build_tree_list (NULL_TREE, $3)); }
  919.     | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
  920.         { $$ = tree_cons ($1, NULL_TREE,
  921.                   tree_cons (NULL_TREE, $3, $5)); }
  922.     | any_word '(' nonnull_exprlist ')'
  923.         { $$ = tree_cons ($1, NULL_TREE, $3); }
  924.     ;
  925.  
  926. /* This still leaves out most reserved keywords,
  927.    shouldn't we include them?  */
  928.  
  929. any_word:
  930.       identifier
  931.     | SCSPEC
  932.     | TYPESPEC
  933.     | TYPE_QUAL
  934.     ;
  935.  
  936. /* Initializers.  `init' is the entry point.  */
  937.  
  938. init:
  939.     expr_no_commas
  940.     | '{'
  941.         { really_start_incremental_init (NULL_TREE);
  942.           /* Note that the call to clear_momentary
  943.              is in process_init_element.  */
  944.           push_momentary (); }
  945.       initlist_maybe_comma '}'
  946.         { $$ = pop_init_level (0);
  947.           if ($$ == error_mark_node
  948.               && ! (yychar == STRING || yychar == CONSTANT))
  949.             pop_momentary ();
  950.           else
  951.             pop_momentary_nofree (); }
  952.  
  953.     | error
  954.         { $$ = error_mark_node; }
  955.     ;
  956.  
  957. /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
  958. initlist_maybe_comma:
  959.       /* empty */
  960.         { if (pedantic)
  961.             pedwarn ("ANSI C forbids empty initializer braces"); }
  962.     | initlist1 maybecomma
  963.     ;
  964.  
  965. initlist1:
  966.       initelt
  967.     | initlist1 ',' initelt
  968.     ;
  969.  
  970. /* `initelt' is a single element of an initializer.
  971.    It may use braces.  */
  972. initelt:
  973.     expr_no_commas
  974.         { process_init_element ($1); }
  975.     | '{' 
  976.         { push_init_level (0); }
  977.       initlist_maybe_comma '}'
  978.         { process_init_element (pop_init_level (0)); }
  979.     | error
  980.     /* These are for labeled elements.  The syntax for an array element
  981.        initializer conflicts with the syntax for an Objective-C message,
  982.        so don't include these productions in the Objective-C grammer.  */
  983.     | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
  984.         { set_init_index ($2, $4); }
  985.       initelt
  986.     | '[' expr_no_commas ']' '='
  987.         { set_init_index ($2, NULL_TREE); }
  988.       initelt
  989.     | '[' expr_no_commas ']'
  990.         { set_init_index ($2, NULL_TREE); }
  991.       initelt
  992.     | identifier ':'
  993.         { set_init_label ($1); }
  994.       initelt
  995.     | '.' identifier '='
  996.         { set_init_label ($2); }
  997.       initelt
  998.     ;
  999.  
  1000. nested_function:
  1001.       declarator
  1002.         { push_c_function_context ();
  1003.           if (! start_function (current_declspecs, $1, 1))
  1004.             {
  1005.               pop_c_function_context ();
  1006.               YYERROR1;
  1007.             }
  1008.           reinit_parse_for_function ();
  1009.           store_parm_decls (); }
  1010. /* This used to use compstmt_or_error.
  1011.    That caused a bug with input `f(g) int g {}',
  1012.    where the use of YYERROR1 above caused an error
  1013.    which then was handled by compstmt_or_error.
  1014.    There followed a repeated execution of that same rule,
  1015.    which called YYERROR1 again, and so on.  */
  1016.       compstmt
  1017.         { finish_function (1);
  1018.           pop_c_function_context (); }
  1019.     ;
  1020.  
  1021. notype_nested_function:
  1022.       notype_declarator
  1023.         { push_c_function_context ();
  1024.           if (! start_function (current_declspecs, $1, 1))
  1025.             {
  1026.               pop_c_function_context ();
  1027.               YYERROR1;
  1028.             }
  1029.           reinit_parse_for_function ();
  1030.           store_parm_decls (); }
  1031. /* This used to use compstmt_or_error.
  1032.    That caused a bug with input `f(g) int g {}',
  1033.    where the use of YYERROR1 above caused an error
  1034.    which then was handled by compstmt_or_error.
  1035.    There followed a repeated execution of that same rule,
  1036.    which called YYERROR1 again, and so on.  */
  1037.       compstmt
  1038.         { finish_function (1);
  1039.           pop_c_function_context (); }
  1040.     ;
  1041.  
  1042. /* Any kind of declarator (thus, all declarators allowed
  1043.    after an explicit typespec).  */
  1044.  
  1045. declarator:
  1046.       after_type_declarator
  1047.     | notype_declarator
  1048.     ;
  1049.  
  1050. /* A declarator that is allowed only after an explicit typespec.  */
  1051.  
  1052. after_type_declarator:
  1053.       '(' after_type_declarator ')'
  1054.         { $$ = $2; }
  1055.     | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
  1056.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1057. /*    | after_type_declarator '(' error ')'  %prec '.'
  1058.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1059.           poplevel (0, 0, 0); }  */
  1060.     | after_type_declarator '[' expr ']'  %prec '.'
  1061.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1062.     | after_type_declarator '[' ']'  %prec '.'
  1063.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1064.     | '*' type_quals after_type_declarator  %prec UNARY
  1065.         { $$ = make_pointer_declarator ($2, $3); }
  1066.     | TYPENAME
  1067.     ;
  1068.  
  1069. /* Kinds of declarator that can appear in a parameter list
  1070.    in addition to notype_declarator.  This is like after_type_declarator
  1071.    but does not allow a typedef name in parentheses as an identifier
  1072.    (because it would conflict with a function with that typedef as arg).  */
  1073.  
  1074. parm_declarator:
  1075.       parm_declarator '(' parmlist_or_identifiers  %prec '.'
  1076.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1077. /*    | parm_declarator '(' error ')'  %prec '.'
  1078.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1079.           poplevel (0, 0, 0); }  */
  1080.     | parm_declarator '[' expr ']'  %prec '.'
  1081.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1082.     | parm_declarator '[' ']'  %prec '.'
  1083.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1084.     | '*' type_quals parm_declarator  %prec UNARY
  1085.         { $$ = make_pointer_declarator ($2, $3); }
  1086.     | TYPENAME
  1087.     ;
  1088.  
  1089. /* A declarator allowed whether or not there has been
  1090.    an explicit typespec.  These cannot redeclare a typedef-name.  */
  1091.  
  1092. notype_declarator:
  1093.       notype_declarator '(' parmlist_or_identifiers  %prec '.'
  1094.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1095. /*    | notype_declarator '(' error ')'  %prec '.'
  1096.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1097.           poplevel (0, 0, 0); }  */
  1098.     | '(' notype_declarator ')'
  1099.         { $$ = $2; }
  1100.     | '*' type_quals notype_declarator  %prec UNARY
  1101.         { $$ = make_pointer_declarator ($2, $3); }
  1102.     | notype_declarator '[' expr ']'  %prec '.'
  1103.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1104.     | notype_declarator '[' ']'  %prec '.'
  1105.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1106.     | IDENTIFIER
  1107.     ;
  1108.  
  1109. structsp:
  1110.       STRUCT identifier '{'
  1111.         { $$ = start_struct (RECORD_TYPE, $2);
  1112.           /* Start scope of tag before parsing components.  */
  1113.         }
  1114.       component_decl_list '}'
  1115.         { $$ = finish_struct ($<ttype>4, $5);
  1116.           /* Really define the structure.  */
  1117.         }
  1118.     | STRUCT '{' component_decl_list '}'
  1119.         { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
  1120.                       $3); }
  1121.     | STRUCT identifier
  1122.         { $$ = xref_tag (RECORD_TYPE, $2); }
  1123.     | UNION identifier '{'
  1124.         { $$ = start_struct (UNION_TYPE, $2); }
  1125.       component_decl_list '}'
  1126.         { $$ = finish_struct ($<ttype>4, $5); }
  1127.     | UNION '{' component_decl_list '}'
  1128.         { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
  1129.                       $3); }
  1130.     | UNION identifier
  1131.         { $$ = xref_tag (UNION_TYPE, $2); }
  1132.     | ENUM identifier '{'
  1133.         { $<itype>3 = suspend_momentary ();
  1134.           $$ = start_enum ($2); }
  1135.       enumlist maybecomma_warn '}'
  1136.         { $$ = finish_enum ($<ttype>4, nreverse ($5));
  1137.           resume_momentary ($<itype>3); }
  1138.     | ENUM '{'
  1139.         { $<itype>2 = suspend_momentary ();
  1140.           $$ = start_enum (NULL_TREE); }
  1141.       enumlist maybecomma_warn '}'
  1142.         { $$ = finish_enum ($<ttype>3, nreverse ($4));
  1143.           resume_momentary ($<itype>2); }
  1144.     | ENUM identifier
  1145.         { $$ = xref_tag (ENUMERAL_TYPE, $2); }
  1146.     ;
  1147.  
  1148. maybecomma:
  1149.       /* empty */
  1150.     | ','
  1151.     ;
  1152.  
  1153. maybecomma_warn:
  1154.       /* empty */
  1155.     | ','
  1156.         { if (pedantic) pedwarn ("comma at end of enumerator list"); }
  1157.     ;
  1158.  
  1159. component_decl_list:
  1160.       component_decl_list2
  1161.         { $$ = $1; }
  1162.     | component_decl_list2 component_decl
  1163.         { $$ = chainon ($1, $2);
  1164.           pedwarn ("no semicolon at end of struct or union"); }
  1165.     ;
  1166.  
  1167. component_decl_list2:    /* empty */
  1168.         { $$ = NULL_TREE; }
  1169.     | component_decl_list2 component_decl ';'
  1170.         { $$ = chainon ($1, $2); }
  1171.     | component_decl_list2 ';'
  1172.         { if (pedantic)
  1173.             pedwarn ("extra semicolon in struct or union specified"); }
  1174.     ;
  1175.  
  1176. /* There is a shift-reduce conflict here, because `components' may
  1177.    start with a `typename'.  It happens that shifting (the default resolution)
  1178.    does the right thing, because it treats the `typename' as part of
  1179.    a `typed_typespecs'.
  1180.  
  1181.    It is possible that this same technique would allow the distinction
  1182.    between `notype_initdecls' and `initdecls' to be eliminated.
  1183.    But I am being cautious and not trying it.  */
  1184.  
  1185. component_decl:
  1186.       typed_typespecs setspecs components
  1187.         { $$ = $3;
  1188.           current_declspecs = TREE_VALUE (declspec_stack);
  1189.           declspec_stack = TREE_CHAIN (declspec_stack);
  1190.           resume_momentary ($2); }
  1191.     | typed_typespecs
  1192.         { if (pedantic)
  1193.             pedwarn ("ANSI C forbids member declarations with no members");
  1194.           shadow_tag($1);
  1195.           $$ = NULL_TREE; }
  1196.     | nonempty_type_quals setspecs components
  1197.         { $$ = $3;
  1198.           current_declspecs = TREE_VALUE (declspec_stack);
  1199.           declspec_stack = TREE_CHAIN (declspec_stack);
  1200.           resume_momentary ($2); }
  1201.     | nonempty_type_quals
  1202.         { if (pedantic)
  1203.             pedwarn ("ANSI C forbids member declarations with no members");
  1204.           shadow_tag($1);
  1205.           $$ = NULL_TREE; }
  1206.     | error
  1207.         { $$ = NULL_TREE; }
  1208.     ;
  1209.  
  1210. components:
  1211.       component_declarator
  1212.     | components ',' component_declarator
  1213.         { $$ = chainon ($1, $3); }
  1214.     ;
  1215.  
  1216. component_declarator:
  1217.       save_filename save_lineno declarator maybe_attribute
  1218.         { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1219.           decl_attributes ($$, $4); }
  1220.     | save_filename save_lineno
  1221.       declarator ':' expr_no_commas maybe_attribute
  1222.         { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1223.           decl_attributes ($$, $6); }
  1224.     | save_filename save_lineno ':' expr_no_commas maybe_attribute
  1225.         { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
  1226.           decl_attributes ($$, $5); }
  1227.     ;
  1228.  
  1229. /* We chain the enumerators in reverse order.
  1230.    They are put in forward order where enumlist is used.
  1231.    (The order used to be significant, but no longer is so.
  1232.    However, we still maintain the order, just to be clean.)  */
  1233.  
  1234. enumlist:
  1235.       enumerator
  1236.     | enumlist ',' enumerator
  1237.         { $$ = chainon ($3, $1); }
  1238.     | error
  1239.         { $$ = error_mark_node; }
  1240.     ;
  1241.  
  1242.  
  1243. enumerator:
  1244.       identifier
  1245.         { $$ = build_enumerator ($1, NULL_TREE); }
  1246.     | identifier '=' expr_no_commas
  1247.         { $$ = build_enumerator ($1, $3); }
  1248.     ;
  1249.  
  1250. typename:
  1251.     typed_typespecs absdcl
  1252.         { $$ = build_tree_list ($1, $2); }
  1253.     | nonempty_type_quals absdcl
  1254.         { $$ = build_tree_list ($1, $2); }
  1255.     ;
  1256.  
  1257. absdcl:   /* an absolute declarator */
  1258.     /* empty */
  1259.         { $$ = NULL_TREE; }
  1260.     | absdcl1
  1261.     ;
  1262.  
  1263. nonempty_type_quals:
  1264.       TYPE_QUAL
  1265.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1266.     | nonempty_type_quals TYPE_QUAL
  1267.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1268.     ;
  1269.  
  1270. type_quals:
  1271.       /* empty */
  1272.         { $$ = NULL_TREE; }
  1273.     | type_quals TYPE_QUAL
  1274.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1275.     ;
  1276.  
  1277. absdcl1:  /* a nonempty absolute declarator */
  1278.       '(' absdcl1 ')'
  1279.         { $$ = $2; }
  1280.       /* `(typedef)1' is `int'.  */
  1281.     | '*' type_quals absdcl1  %prec UNARY
  1282.         { $$ = make_pointer_declarator ($2, $3); }
  1283.     | '*' type_quals  %prec UNARY
  1284.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  1285.     | absdcl1 '(' parmlist  %prec '.'
  1286.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1287.     | absdcl1 '[' expr ']'  %prec '.'
  1288.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1289.     | absdcl1 '[' ']'  %prec '.'
  1290.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1291.     | '(' parmlist  %prec '.'
  1292.         { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
  1293.     | '[' expr ']'  %prec '.'
  1294.         { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
  1295.     | '[' ']'  %prec '.'
  1296.         { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
  1297.     ;
  1298.  
  1299. /* at least one statement, the first of which parses without error.  */
  1300. /* stmts is used only after decls, so an invalid first statement
  1301.    is actually regarded as an invalid decl and part of the decls.  */
  1302.  
  1303. stmts:
  1304.       lineno_stmt_or_label
  1305.     | stmts lineno_stmt_or_label
  1306.     | stmts errstmt
  1307.     ;
  1308.  
  1309. xstmts:
  1310.     /* empty */
  1311.     | stmts
  1312.     ;
  1313.  
  1314. errstmt:  error ';'
  1315.     ;
  1316.  
  1317. pushlevel:  /* empty */
  1318.         { emit_line_note (input_filename, lineno);
  1319.           pushlevel (0);
  1320.           clear_last_expr ();
  1321.           push_momentary ();
  1322.           expand_start_bindings (0);
  1323.         }
  1324.     ;
  1325.  
  1326. /* Read zero or more forward-declarations for labels
  1327.    that nested functions can jump to.  */
  1328. maybe_label_decls:
  1329.       /* empty */
  1330.     | label_decls
  1331.         { if (pedantic)
  1332.             pedwarn ("ANSI C forbids label declarations"); }
  1333.     ;
  1334.  
  1335. label_decls:
  1336.       label_decl
  1337.     | label_decls label_decl
  1338.     ;
  1339.  
  1340. label_decl:
  1341.       LABEL identifiers_or_typenames ';'
  1342.         { tree link;
  1343.           for (link = $2; link; link = TREE_CHAIN (link))
  1344.             {
  1345.               tree label = shadow_label (TREE_VALUE (link));
  1346.               C_DECLARED_LABEL_FLAG (label) = 1;
  1347.               declare_nonlocal_label (label);
  1348.             }
  1349.         }
  1350.     ;
  1351.  
  1352. /* This is the body of a function definition.
  1353.    It causes syntax errors to ignore to the next openbrace.  */
  1354. compstmt_or_error:
  1355.       compstmt
  1356.         {}
  1357.     | error compstmt
  1358.     ;
  1359.  
  1360. compstmt: '{' '}'
  1361.         { $$ = convert (void_type_node, integer_zero_node); }
  1362.     | '{' pushlevel maybe_label_decls decls xstmts '}'
  1363.         { emit_line_note (input_filename, lineno);
  1364.           expand_end_bindings (getdecls (), 1, 0);
  1365.           $$ = poplevel (1, 1, 0);
  1366.           if (yychar == CONSTANT || yychar == STRING)
  1367.             pop_momentary_nofree ();
  1368.           else
  1369.             pop_momentary (); }
  1370.     | '{' pushlevel maybe_label_decls error '}'
  1371.         { emit_line_note (input_filename, lineno);
  1372.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1373.           $$ = poplevel (kept_level_p (), 0, 0);
  1374.           if (yychar == CONSTANT || yychar == STRING)
  1375.             pop_momentary_nofree ();
  1376.           else
  1377.             pop_momentary (); }
  1378.     | '{' pushlevel maybe_label_decls stmts '}'
  1379.         { emit_line_note (input_filename, lineno);
  1380.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1381.           $$ = poplevel (kept_level_p (), 0, 0);
  1382.           if (yychar == CONSTANT || yychar == STRING)
  1383.             pop_momentary_nofree ();
  1384.           else
  1385.             pop_momentary (); }
  1386.     ;
  1387.  
  1388. /* Value is number of statements counted as of the closeparen.  */
  1389. simple_if:
  1390.       if_prefix lineno_labeled_stmt
  1391. /* Make sure expand_end_cond is run once
  1392.    for each call to expand_start_cond.
  1393.    Otherwise a crash is likely.  */
  1394.     | if_prefix error
  1395.     ;
  1396.  
  1397. if_prefix:
  1398.       IF '(' expr ')'
  1399.         { emit_line_note ($<filename>-1, $<lineno>0);
  1400.           expand_start_cond (truthvalue_conversion ($3), 0);
  1401.           $<itype>$ = stmt_count;
  1402.           if_stmt_file = $<filename>-1;
  1403.           if_stmt_line = $<lineno>0;
  1404.           position_after_white_space (); }
  1405.     ;
  1406.  
  1407. /* This is a subroutine of stmt.
  1408.    It is used twice, once for valid DO statements
  1409.    and once for catching errors in parsing the end test.  */
  1410. do_stmt_start:
  1411.       DO
  1412.         { stmt_count++;
  1413.           emit_line_note ($<filename>-1, $<lineno>0);
  1414.           /* See comment in `while' alternative, above.  */
  1415.           emit_nop ();
  1416.           expand_start_loop_continue_elsewhere (1);
  1417.           position_after_white_space (); }
  1418.       lineno_labeled_stmt WHILE
  1419.         { expand_loop_continue_here (); }
  1420.     ;
  1421.  
  1422. save_filename:
  1423.         { $$ = input_filename; }
  1424.     ;
  1425.  
  1426. save_lineno:
  1427.         { $$ = lineno; }
  1428.     ;
  1429.  
  1430. lineno_labeled_stmt:
  1431.       save_filename save_lineno stmt
  1432.         { }
  1433. /*    | save_filename save_lineno error
  1434.         { }
  1435. */
  1436.     | save_filename save_lineno label lineno_labeled_stmt
  1437.         { }
  1438.     ;
  1439.  
  1440. lineno_stmt_or_label:
  1441.       save_filename save_lineno stmt_or_label
  1442.         { }
  1443.     ;
  1444.  
  1445. stmt_or_label:
  1446.       stmt
  1447.     | label
  1448.         { int next;
  1449.           position_after_white_space ();
  1450.           next = getc (finput);
  1451.           ungetc (next, finput);
  1452.           if (pedantic && next == '}')
  1453.             pedwarn ("ANSI C forbids label at end of compound statement");
  1454.         }
  1455.     ;
  1456.  
  1457. /* Parse a single real statement, not including any labels.  */
  1458. stmt:
  1459.       compstmt
  1460.         { stmt_count++; }
  1461.         | all_iter_stmt 
  1462.     | expr ';'
  1463.         { stmt_count++;
  1464.           emit_line_note ($<filename>-1, $<lineno>0);
  1465. /* It appears that this should not be done--that a non-lvalue array
  1466.    shouldn't get an error if the value isn't used.
  1467.    Section 3.2.2.1 says that an array lvalue gets converted to a pointer
  1468.    if it appears as a top-level expression,
  1469.    but says nothing about non-lvalue arrays.  */
  1470. #if 0
  1471.           /* Call default_conversion to get an error
  1472.              on referring to a register array if pedantic.  */
  1473.           if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
  1474.               || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
  1475.             $1 = default_conversion ($1);
  1476. #endif
  1477.           iterator_expand ($1);
  1478.           clear_momentary (); }
  1479.     | simple_if ELSE
  1480.         { expand_start_else ();
  1481.           $<itype>1 = stmt_count;
  1482.           position_after_white_space (); }
  1483.       lineno_labeled_stmt
  1484.         { expand_end_cond ();
  1485.           if (extra_warnings && stmt_count == $<itype>1)
  1486.             warning ("empty body in an else-statement"); }
  1487.     | simple_if %prec IF
  1488.         { expand_end_cond ();
  1489.           /* This warning is here instead of in simple_if, because we
  1490.              do not want a warning if an empty if is followed by an
  1491.              else statement.  Increment stmt_count so we don't
  1492.              give a second error if this is a nested `if'.  */
  1493.           if (extra_warnings && stmt_count++ == $<itype>1)
  1494.             warning_with_file_and_line (if_stmt_file, if_stmt_line,
  1495.                         "empty body in an if-statement"); }
  1496. /* Make sure expand_end_cond is run once
  1497.    for each call to expand_start_cond.
  1498.    Otherwise a crash is likely.  */
  1499.     | simple_if ELSE error
  1500.         { expand_end_cond (); }
  1501.     | WHILE
  1502.         { stmt_count++;
  1503.           emit_line_note ($<filename>-1, $<lineno>0);
  1504.           /* The emit_nop used to come before emit_line_note,
  1505.              but that made the nop seem like part of the preceding line.
  1506.              And that was confusing when the preceding line was
  1507.              inside of an if statement and was not really executed.
  1508.              I think it ought to work to put the nop after the line number.
  1509.              We will see.  --rms, July 15, 1991.  */
  1510.           emit_nop (); }
  1511.       '(' expr ')'
  1512.         { /* Don't start the loop till we have succeeded
  1513.              in parsing the end test.  This is to make sure
  1514.              that we end every loop we start.  */
  1515.           expand_start_loop (1);
  1516.           emit_line_note (input_filename, lineno);
  1517.           expand_exit_loop_if_false (NULL_PTR,
  1518.                          truthvalue_conversion ($4));
  1519.           position_after_white_space (); }
  1520.       lineno_labeled_stmt
  1521.         { expand_end_loop (); }
  1522.     | do_stmt_start
  1523.       '(' expr ')' ';'
  1524.         { emit_line_note (input_filename, lineno);
  1525.           expand_exit_loop_if_false (NULL_PTR,
  1526.                          truthvalue_conversion ($3));
  1527.           expand_end_loop ();
  1528.           clear_momentary (); }
  1529. /* This rule is needed to make sure we end every loop we start.  */
  1530.     | do_stmt_start error
  1531.         { expand_end_loop ();
  1532.           clear_momentary (); }
  1533.     | FOR
  1534.       '(' xexpr ';'
  1535.         { stmt_count++;
  1536.           emit_line_note ($<filename>-1, $<lineno>0);
  1537.           /* See comment in `while' alternative, above.  */
  1538.           emit_nop ();
  1539.           if ($3) c_expand_expr_stmt ($3);
  1540.           /* Next step is to call expand_start_loop_continue_elsewhere,
  1541.              but wait till after we parse the entire for (...).
  1542.              Otherwise, invalid input might cause us to call that
  1543.              fn without calling expand_end_loop.  */
  1544.         }
  1545.       xexpr ';'
  1546.         /* Can't emit now; wait till after expand_start_loop...  */
  1547.         { $<lineno>7 = lineno;
  1548.           $<filename>$ = input_filename; }
  1549.       xexpr ')'
  1550.         { 
  1551.           /* Start the loop.  Doing this after parsing
  1552.              all the expressions ensures we will end the loop.  */
  1553.           expand_start_loop_continue_elsewhere (1);
  1554.           /* Emit the end-test, with a line number.  */
  1555.           emit_line_note ($<filename>8, $<lineno>7);
  1556.           if ($6)
  1557.             expand_exit_loop_if_false (NULL_PTR,
  1558.                            truthvalue_conversion ($6));
  1559.           /* Don't let the tree nodes for $9 be discarded by
  1560.              clear_momentary during the parsing of the next stmt.  */
  1561.           push_momentary ();
  1562.           $<lineno>7 = lineno;
  1563.           $<filename>8 = input_filename;
  1564.           position_after_white_space (); }
  1565.       lineno_labeled_stmt
  1566.         { /* Emit the increment expression, with a line number.  */
  1567.           emit_line_note ($<filename>8, $<lineno>7);
  1568.           expand_loop_continue_here ();
  1569.           if ($9)
  1570.             c_expand_expr_stmt ($9);
  1571.           if (yychar == CONSTANT || yychar == STRING)
  1572.             pop_momentary_nofree ();
  1573.           else
  1574.             pop_momentary ();
  1575.           expand_end_loop (); }
  1576.     | SWITCH '(' expr ')'
  1577.         { stmt_count++;
  1578.           emit_line_note ($<filename>-1, $<lineno>0);
  1579.           c_expand_start_case ($3);
  1580.           /* Don't let the tree nodes for $3 be discarded by
  1581.              clear_momentary during the parsing of the next stmt.  */
  1582.           push_momentary ();
  1583.           position_after_white_space (); }
  1584.       lineno_labeled_stmt
  1585.         { expand_end_case ($3);
  1586.           if (yychar == CONSTANT || yychar == STRING)
  1587.             pop_momentary_nofree ();
  1588.           else
  1589.             pop_momentary (); }
  1590.     | BREAK ';'
  1591.         { stmt_count++;
  1592.           emit_line_note ($<filename>-1, $<lineno>0);
  1593.           if ( ! expand_exit_something ())
  1594.             error ("break statement not within loop or switch"); }
  1595.     | CONTINUE ';'
  1596.         { stmt_count++;
  1597.           emit_line_note ($<filename>-1, $<lineno>0);
  1598.           if (! expand_continue_loop (NULL_PTR))
  1599.             error ("continue statement not within a loop"); }
  1600.     | RETURN ';'
  1601.         { stmt_count++;
  1602.           emit_line_note ($<filename>-1, $<lineno>0);
  1603.           c_expand_return (NULL_TREE); }
  1604.     | RETURN expr ';'
  1605.         { stmt_count++;
  1606.           emit_line_note ($<filename>-1, $<lineno>0);
  1607.           c_expand_return ($2); }
  1608.     | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
  1609.         { stmt_count++;
  1610.           emit_line_note ($<filename>-1, $<lineno>0);
  1611.           STRIP_NOPS ($4);
  1612.           if ((TREE_CODE ($4) == ADDR_EXPR
  1613.                && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
  1614.               || TREE_CODE ($4) == STRING_CST)
  1615.             expand_asm ($4);
  1616.           else
  1617.             error ("argument of `asm' is not a constant string"); }
  1618.     /* This is the case with just output operands.  */
  1619.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
  1620.         { stmt_count++;
  1621.           emit_line_note ($<filename>-1, $<lineno>0);
  1622.           c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
  1623.                      $2 == ridpointers[(int)RID_VOLATILE],
  1624.                      input_filename, lineno); }
  1625.     /* This is the case with input operands as well.  */
  1626.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  1627.         { stmt_count++;
  1628.           emit_line_note ($<filename>-1, $<lineno>0);
  1629.           c_expand_asm_operands ($4, $6, $8, NULL_TREE,
  1630.                      $2 == ridpointers[(int)RID_VOLATILE],
  1631.                      input_filename, lineno); }
  1632.     /* This is the case with clobbered registers as well.  */
  1633.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  1634.         asm_operands ':' asm_clobbers ')' ';'
  1635.         { stmt_count++;
  1636.           emit_line_note ($<filename>-1, $<lineno>0);
  1637.           c_expand_asm_operands ($4, $6, $8, $10,
  1638.                      $2 == ridpointers[(int)RID_VOLATILE],
  1639.                      input_filename, lineno); }
  1640.     | GOTO identifier ';'
  1641.         { tree decl;
  1642.           stmt_count++;
  1643.           emit_line_note ($<filename>-1, $<lineno>0);
  1644.           decl = lookup_label ($2);
  1645.           if (decl != 0)
  1646.             {
  1647.               TREE_USED (decl) = 1;
  1648.               expand_goto (decl);
  1649.             }
  1650.         }
  1651.     | GOTO '*' expr ';'
  1652.         { stmt_count++;
  1653.           emit_line_note ($<filename>-1, $<lineno>0);
  1654.           expand_computed_goto (convert (ptr_type_node, $3)); }
  1655.     | ';'
  1656.     ;
  1657.  
  1658. all_iter_stmt:
  1659.       all_iter_stmt_simple
  1660. /*    | all_iter_stmt_with_decl */
  1661.     ;
  1662.  
  1663. all_iter_stmt_simple:
  1664.       FOR '(' primary ')' 
  1665.       {
  1666.         /* The value returned by this action is  */
  1667.         /*      1 if everything is OK */ 
  1668.         /*      0 in case of error or already bound iterator */
  1669.  
  1670.         $<itype>$ = 0;
  1671.         if (TREE_CODE ($3) != VAR_DECL)
  1672.           error ("invalid `for (ITERATOR)' syntax");
  1673.         else if (! ITERATOR_P ($3))
  1674.           error ("`%s' is not an iterator",
  1675.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1676.         else if (ITERATOR_BOUND_P ($3))
  1677.           error ("`for (%s)' inside expansion of same iterator",
  1678.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1679.         else
  1680.           {
  1681.         $<itype>$ = 1;
  1682.         iterator_for_loop_start ($3);
  1683.           }
  1684.       }
  1685.       lineno_labeled_stmt
  1686.       {
  1687.         if ($<itype>5)
  1688.           iterator_for_loop_end ($3);
  1689.       }
  1690.  
  1691. /*  This really should allow any kind of declaration,
  1692.     for generality.  Fix it before turning it back on.
  1693.  
  1694. all_iter_stmt_with_decl:
  1695.       FOR '(' ITERATOR pushlevel setspecs iterator_spec ')' 
  1696.       {
  1697. */        /* The value returned by this action is  */
  1698.         /*      1 if everything is OK */ 
  1699.         /*      0 in case of error or already bound iterator */
  1700. /*
  1701.         iterator_for_loop_start ($6);
  1702.       }
  1703.       lineno_labeled_stmt
  1704.       {
  1705.         iterator_for_loop_end ($6);
  1706.         emit_line_note (input_filename, lineno);
  1707.         expand_end_bindings (getdecls (), 1, 0);
  1708.         $<ttype>$ = poplevel (1, 1, 0);
  1709.         if (yychar == CONSTANT || yychar == STRING)
  1710.           pop_momentary_nofree ();
  1711.         else
  1712.           pop_momentary ();        
  1713.       }
  1714. */
  1715.  
  1716. /* Any kind of label, including jump labels and case labels.
  1717.    ANSI C accepts labels only before statements, but we allow them
  1718.    also at the end of a compound statement.  */
  1719.  
  1720. label:      CASE expr_no_commas ':'
  1721.         { register tree value = check_case_value ($2);
  1722.           register tree label
  1723.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1724.  
  1725.           stmt_count++;
  1726.  
  1727.           if (value != error_mark_node)
  1728.             {
  1729.               tree duplicate;
  1730.               int success = pushcase (value, convert_and_check,
  1731.                           label, &duplicate);
  1732.               if (success == 1)
  1733.             error ("case label not within a switch statement");
  1734.               else if (success == 2)
  1735.             {
  1736.               error ("duplicate case value");
  1737.               error_with_decl (duplicate, "this is the first entry for that value");
  1738.             }
  1739.               else if (success == 3)
  1740.             warning ("case value out of range");
  1741.               else if (success == 5)
  1742.             error ("case label within scope of cleanup or variable array");
  1743.             }
  1744.           position_after_white_space (); }
  1745.     | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
  1746.         { register tree value1 = check_case_value ($2);
  1747.           register tree value2 = check_case_value ($4);
  1748.           register tree label
  1749.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1750.  
  1751.           stmt_count++;
  1752.  
  1753.           if (value1 != error_mark_node && value2 != error_mark_node)
  1754.             {
  1755.               tree duplicate;
  1756.               int success = pushcase_range (value1, value2,
  1757.                             convert_and_check, label,
  1758.                             &duplicate);
  1759.               if (success == 1)
  1760.             error ("case label not within a switch statement");
  1761.               else if (success == 2)
  1762.             {
  1763.               error ("duplicate case value");
  1764.               error_with_decl (duplicate, "this is the first entry for that value");
  1765.             }
  1766.               else if (success == 3)
  1767.             warning ("case value out of range");
  1768.               else if (success == 4)
  1769.             warning ("empty case range");
  1770.               else if (success == 5)
  1771.             error ("case label within scope of cleanup or variable array");
  1772.             }
  1773.           position_after_white_space (); }
  1774.     | DEFAULT ':'
  1775.         {
  1776.           tree duplicate;
  1777.           register tree label
  1778.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1779.           int success = pushcase (NULL_TREE, 0, label, &duplicate);
  1780.           stmt_count++;
  1781.           if (success == 1)
  1782.             error ("default label not within a switch statement");
  1783.           else if (success == 2)
  1784.             {
  1785.               error ("multiple default labels in one switch");
  1786.               error_with_decl (duplicate, "this is the first default label");
  1787.             }
  1788.           position_after_white_space (); }
  1789.     | identifier ':'
  1790.         { tree label = define_label (input_filename, lineno, $1);
  1791.           stmt_count++;
  1792.           emit_nop ();
  1793.           if (label)
  1794.             expand_label (label);
  1795.           position_after_white_space (); }
  1796.     ;
  1797.  
  1798. /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
  1799.  
  1800. maybe_type_qual:
  1801.     /* empty */
  1802.         { emit_line_note (input_filename, lineno);
  1803.           $$ = NULL_TREE; }
  1804.     | TYPE_QUAL
  1805.         { emit_line_note (input_filename, lineno); }
  1806.     ;
  1807.  
  1808. xexpr:
  1809.     /* empty */
  1810.         { $$ = NULL_TREE; }
  1811.     | expr
  1812.     ;
  1813.  
  1814. /* These are the operands other than the first string and colon
  1815.    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
  1816. asm_operands: /* empty */
  1817.         { $$ = NULL_TREE; }
  1818.     | nonnull_asm_operands
  1819.     ;
  1820.  
  1821. nonnull_asm_operands:
  1822.       asm_operand
  1823.     | nonnull_asm_operands ',' asm_operand
  1824.         { $$ = chainon ($1, $3); }
  1825.     ;
  1826.  
  1827. asm_operand:
  1828.       STRING '(' expr ')'
  1829.         { $$ = build_tree_list ($1, $3); }
  1830.     ;
  1831.  
  1832. asm_clobbers:
  1833.       string
  1834.         { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
  1835.     | asm_clobbers ',' string
  1836.         { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
  1837.     ;
  1838.  
  1839. /* This is what appears inside the parens in a function declarator.
  1840.    Its value is a list of ..._TYPE nodes.  */
  1841. parmlist:
  1842.         { pushlevel (0);
  1843.           clear_parm_order ();
  1844.           declare_parm_level (0); }
  1845.       parmlist_1
  1846.         { $$ = $2;
  1847.           parmlist_tags_warning ();
  1848.           poplevel (0, 0, 0); }
  1849.     ;
  1850.  
  1851. parmlist_1:
  1852.       parmlist_2 ')'
  1853.     | parms ';'
  1854.         { tree parm;
  1855.           if (pedantic)
  1856.             pedwarn ("ANSI C forbids forward parameter declarations");
  1857.           /* Mark the forward decls as such.  */
  1858.           for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
  1859.             TREE_ASM_WRITTEN (parm) = 1;
  1860.           clear_parm_order (); }
  1861.       parmlist_1
  1862.         { $$ = $4; }
  1863.     | error ')'
  1864.         { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
  1865.     ;
  1866.  
  1867. /* This is what appears inside the parens in a function declarator.
  1868.    Is value is represented in the format that grokdeclarator expects.  */
  1869. parmlist_2:  /* empty */
  1870.         { $$ = get_parm_info (0); }
  1871.     | ELLIPSIS
  1872.         { $$ = get_parm_info (0);
  1873.           /* Gcc used to allow this as an extension.  However, it does
  1874.              not work for all targets, and thus has been disabled.
  1875.              Also, since func (...) and func () are indistinguishable,
  1876.              it caused problems with the code in expand_builtin which
  1877.              tries to verify that BUILT_IN_NEXT_ARG is being used
  1878.              correctly.  */
  1879.           error ("ANSI C requires a named argument before `...'");
  1880.         }
  1881.     | parms
  1882.         { $$ = get_parm_info (1); }
  1883.     | parms ',' ELLIPSIS
  1884.         { $$ = get_parm_info (0); }
  1885.     ;
  1886.  
  1887. parms:
  1888.     parm
  1889.         { push_parm_decl ($1); }
  1890.     | parms ',' parm
  1891.         { push_parm_decl ($3); }
  1892.     ;
  1893.  
  1894. /* A single parameter declaration or parameter type name,
  1895.    as found in a parmlist.  */
  1896. parm:
  1897.       typed_declspecs parm_declarator
  1898.         { $$ = build_tree_list ($1, $2)    ; }
  1899.     | typed_declspecs notype_declarator
  1900.         { $$ = build_tree_list ($1, $2)    ; }
  1901.     | typed_declspecs absdcl
  1902.         { $$ = build_tree_list ($1, $2); }
  1903.     | declmods notype_declarator
  1904.         { $$ = build_tree_list ($1, $2)    ; }
  1905.     | declmods absdcl
  1906.         { $$ = build_tree_list ($1, $2); }
  1907.     ;
  1908.  
  1909. /* This is used in a function definition
  1910.    where either a parmlist or an identifier list is ok.
  1911.    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
  1912. parmlist_or_identifiers:
  1913.         { pushlevel (0);
  1914.           clear_parm_order ();
  1915.           declare_parm_level (1); }
  1916.       parmlist_or_identifiers_1
  1917.         { $$ = $2;
  1918.           parmlist_tags_warning ();
  1919.           poplevel (0, 0, 0); }
  1920.     ;
  1921.  
  1922. parmlist_or_identifiers_1:
  1923.       parmlist_1
  1924.     | identifiers ')'
  1925.         { tree t;
  1926.           for (t = $1; t; t = TREE_CHAIN (t))
  1927.             if (TREE_VALUE (t) == NULL_TREE)
  1928.               error ("`...' in old-style identifier list");
  1929.           $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
  1930.     ;
  1931.  
  1932. /* A nonempty list of identifiers.  */
  1933. identifiers:
  1934.     IDENTIFIER
  1935.         { $$ = build_tree_list (NULL_TREE, $1); }
  1936.     | identifiers ',' IDENTIFIER
  1937.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  1938.     ;
  1939.  
  1940. /* A nonempty list of identifiers, including typenames.  */
  1941. identifiers_or_typenames:
  1942.     identifier
  1943.         { $$ = build_tree_list (NULL_TREE, $1); }
  1944.     | identifiers_or_typenames ',' identifier
  1945.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  1946.     ;
  1947.  
  1948. %%
  1949.